package org.grottarossa.template.data.pojo.tasks;

import java.util.Date;

import org.grottarossa.template.data.Marshaler;
import org.grottarossa.template.data.enums.EnumStatus;
import org.grottarossa.template.data.enums.EnumTaskType;
import org.grottarossa.template.data.pojo.Assignee;
import org.grottarossa.template.data.pojo.DeadLine;
import org.grottarossa.template.data.pojo.workflows.WorkItem;
import org.grottarossa.template.drivers.components.tokens.CaseManagementId;
import org.grottarossa.template.drivers.components.tokens.TaskManagementId;
import org.grottarossa.template.drivers.components.tokens.WorkFlowId;

/**
 *
 * La Classe rappresenta l'oggetto Task.
 *
 * @author Marco Sabatini (sabatini.m@gmail.com)
 * @author Maurizio Farina (maurizio.farina@gmail.com)
* @author Marco Trischitta (marco.trischitta@gmail.com)
 * @version %I%, %G%
 * @since 1.0
 *
 * */
public class Task
{
	/**E' l'id del casefolder che contiene il task.*/
	private CaseManagementId taskContainerID; //casefolder for case360
	/**E' l'id del task.*/
	private TaskManagementId taskID;
	/**E' il display name del task.*/
	private String taskName;
	/**E' il nome del task.*/
	private String scriptName;
	/**E' l'utente che ha modificato per ultimo il task.*/
	private String modifiedBy;
	/**E' l'assegnatario del task.*/
	private Assignee assignee = new Assignee();
	/**E' la stringa contenente i commenti del task.*/
	private String comments;
	/**E' l'utente che ha completato il task.*/
	private String completedBy;
	/**E' l'utente che ha creato il task.*/
	private String createdBy;
	/**E' la data di creazione del task.*/
	private Date createdDateTime;
	/**E' la deadline di scadenza del task.*/
	private DeadLine deadLine = new DeadLine();
	/**E' la percentuale di completamento del task.*/
	private int percentCompleted;

	/**E' lo status del task.*/
	private EnumStatus status;

	//process information
	/**Definisce se il task e' o meno un processo.*/
	private boolean isProcess;

	/**E' l'id dell'ipotetico processo che deve essere eseguito nel task.*/
	private WorkFlowId workFlowID;

	/**E' l'id del workitem nel caso in cui il processo fosse istanziato*/
	private String workItemId=null;

	public String getWorkItemId() {
		return workItemId;
	}
	public void setWorkItemId(String workItemId) {
		this.workItemId = workItemId;
	}
	public boolean isIstantiated()
	{
		if(workItemId!=null)
			return true;
		return false;
	}


	/**E' la versione del processo.*/
	private int workFlowVersion;
	/***/
	private String processCaseRepositoryField;//TODO: ???
	/**E' lo script name del processo che deve essere avviato dal task.*/
	private String processTaskScriptNameField;
	/**E' l'enumeratore che identifica se si tratta di una section oppure di un element.*/
	private EnumTaskType type; // 2 or 3



	public void setTaskContainerID(CaseManagementId taskContainerID) {
		this.taskContainerID = taskContainerID;
	}
	public CaseManagementId getTaskContainerID() {
		return taskContainerID;
	}
	public void setTaskID(TaskManagementId taskID) {
		this.taskID = taskID;
	}
	public TaskManagementId getTaskID() {
		return taskID;
	}
	public void setTaskName(String taskName) {
		this.taskName = taskName;

	}
	public String getTaskName() {
		return taskName;
	}
	public void setModifiedBy(String modifiedBy) {
		this.modifiedBy = modifiedBy;
	}
	public String getModifiedBy() {
		return modifiedBy;
	}
	public void setAssignee(Assignee assignee) {
		this.assignee = assignee;
	}
	public Assignee getAssignee() {
		return assignee;
	}
	public void setComments(String comments) {
		this.comments = comments;
	}
	public String getComments() {
		return comments;
	}
	public void setCompletedBy(String completedBy) {
		this.completedBy = completedBy;
	}
	public String getCompletedBy() {
		return completedBy;
	}
	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}
	public String getCreatedBy() {
		return createdBy;
	}
	public void setCreatedDateTime(Date createdDateTime) {
		this.createdDateTime = createdDateTime;
	}
	public Date getCreatedDateTime() {
		return createdDateTime;
	}
	public void setDeadLine(DeadLine deadLine) {
		this.deadLine = deadLine;
	}
	public DeadLine getDeadLine() {
		return deadLine;
	}
	public void setType(EnumTaskType type) {
		this.type = type;
	}
	public EnumTaskType getType() {
		return type;
	}
	public void setPercentCompleted(int percentCompleted) {
		this.percentCompleted = percentCompleted;
	}
	public int getPercentCompleted() {
		return percentCompleted;
	}

	public void setProcess(boolean isProcess) {
		this.isProcess = isProcess;
	}
	public boolean isProcess() {
		return isProcess;
	}
	public void setWorkFlowID(WorkFlowId workFlowID) {
		this.workFlowID = workFlowID;
	}
	public WorkFlowId getWorkFlowID() {
		return workFlowID;
	}
	public void setWorkFlowVersion(int workFlowVersion) {
		this.workFlowVersion = workFlowVersion;
	}
	public int getWorkFlowVersion() {
		return workFlowVersion;
	}
	public void setScriptName(String scriptName) {
		this.scriptName = scriptName;
	}
	public String getScriptName() {
		return scriptName;
	}
	public void setStatus(EnumStatus status) {
		this.status = status;
	}
	public EnumStatus getStatus() {
		return status;
	}
	public boolean isSection()
	{
		return (type.isSection());
	}
	public void setProcessCaseRepositoryField(String processCaseRepositoryField) {
		this.processCaseRepositoryField = processCaseRepositoryField;
	}
	public void setProcessTaskScriptName(String processTaskScriptNameField) {
		this.processTaskScriptNameField = processTaskScriptNameField;
	}

	public String getProcessCaseRepositoryField() {
		return this.processCaseRepositoryField;
	}
	public String getProcessTaskScriptName() {
		return this.processTaskScriptNameField;
	}

	public String toXml()
	{
		return Marshaler.instance().getXstream().toXML(this);
	}
}